package com.usfuture.chart.techanly
{
	import flash.events.EventDispatcher;
	import flash.events.KeyboardEvent;
	import flash.geom.Point;
	import flash.ui.Keyboard;
	
	public class TechPropertyMode1 extends AbstractTechProperty
	{
		
		public function TechPropertyMode1(data:Array){
			this.data = data;
			init();
		}
		
		override protected function init():void{
			mode=true;
			lineNum=90;
			calLinePro();
		}
		
		
		override protected function keyUpHandler():void{
			if (mode)
				lineNum-=lineNum / 8;
			else
				lineNum-=lineNum / 2;
			calLinePro();
		}
		
		override protected function keyDownHandler():void{
			if (mode)
				lineNum+=lineNum / 8;
			else
				lineNum+=lineNum / 2;
			calLinePro();
		}
		
		override protected function keyLeftHandler():void{
			if(relativePos>0) 
				relativePos--;
		}
		
		override protected function keyRightHandler():void{
			relativePos++;
			if(relativePos>=lineNum) 
				relativePos=lineNum-1;
		}
		
		/**
		 * 计算K线属性
		 **/
		private function calLinePro():void
		{
			if (lineNum <= 10)
				lineNum = 10;
			if (lineNum >= data.length)
				lineNum = data.length;
			if (lineNum * 3 >= (AbstractTechProperty.canvasWidth - AbstractTechProperty.leftWidthX - AbstractTechProperty.rightWidthX))
			{
				mode=false;
			}
			else
			{
				mode=true;
				var width:Number=(AbstractTechProperty.canvasWidth - AbstractTechProperty.leftWidthX - AbstractTechProperty.rightWidthX) / (lineNum);
				lineMergin=width * 0.4;
				if (lineMergin >= 5)
					lineMergin=5;
				lineWidth=width - lineMergin;
			}
			if (lineNum > startPos)
			{
				startPos=lineNum;
				
			}
		}

	}
}